package pri.damai.xiaowu.usercenter.api.rpc;

import org.apache.dubbo.config.annotation.DubboService;
import pri.damai.xiaowu.common.core.vo.ResultVO;
import pri.damai.xiaowu.common.dubbo.anno.DubboHandler;
import pri.damai.xiaowu.usercenter.sysuser.application.UserAppService;
import pri.damai.xiaowu.usercenter.common.dto.LoginDTO;
import pri.damai.xiaowu.usercenter.common.dto.UserDTO;

import javax.annotation.Resource;
import java.util.Objects;

/**
 *
 * @Desc
 * @Author DaMai
 * @Date 2022/3/3 18:42
 * 但行好事，莫问前程。
 */
@DubboService
public class UserCenterDubboDubboClient implements pri.damai.xiaowu.usercenter.client.UserCenterDubboClient {

    @Resource
    UserAppService userApp;

    @Override
    @DubboHandler
    public ResultVO<UserDTO> getUser(LoginDTO loginDTO) {

        if (Objects.isNull(loginDTO.getPhone())) {
            throw new RuntimeException("手机号为空");
        }

        UserDTO user = userApp.getUser(loginDTO);

        return ResultVO.success(user);
    }
}
